package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.MaterialDto;
import com.heima.wemedia.service.MaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RequestMapping("/api/v1/material")
@RestController
public class MaterialController {
    @Autowired
    private MaterialService materialService;

    @PostMapping("/list")
    public ResponseResult findList(@RequestBody MaterialDto dto){
        return materialService.findList(dto);
    }

    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile){
        return materialService.uploadPicture(multipartFile);
    }

    @GetMapping("/del_picture/{id}")
    public ResponseResult deleteById(@PathVariable Integer id){
        return materialService.deleteById(id);
    }
}
